/**
 * <p>Copyright (c) 2011 深圳市鹏途信息技术有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	东莞交通工程质量监督综合业务系统        </p>
 * <p>创建者   :	Administrator 
 * 
 * <p>描   述  :   LabsscopeAction.java for com.pengtu.web.project.labs    </p>
 * 
 * <p>最后修改 : $: 2011-8-29-下午02:58:43 v 1.0.0	 Administrator   $     </p>
 * 
*/

package com.pengtu.web.project.labs;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.entity.project.labs.LabsScope;
import com.pengtu.service.project.labs.LabsScopeManager;
import com.pengtu.utils.web.Struts2Utils;
import com.pengtu.web.BaseActionSupport;

/**
 * 
 * LabsscopeAction
 * 
 * 2011-8-29 下午02:58:43
 * 
 * @version 1.0.0
 * 
 */
public class LabsscopeAction extends BaseActionSupport<LabsScope>{

	/**
	 * serialVersionUID:TODO
	 *
	 * @since 1.0.0
	 */
	
	private static final long serialVersionUID = 1L;
	public String id;
	public LabsScope labsScope;
	public String organizationId;
	public String projectId;
	public String deptId;
	public String typeId;
	public Page<LabsScope> page = new Page<LabsScope>(10);
	private LabsScopeManager labsScopeManager;
	@Override
	public LabsScope getModel() {
		return labsScope;
	}

	@Override
	public String list() throws Exception {
		QueryFilter queryfilter = QueryFilter.buildFromHttpRequest(Struts2Utils
				.getRequest());
		queryfilter.addFilter("projectId", projectId);
		queryfilter.addFilter("partId", deptId);
		if (!page.isOrderBySetted()) {
			page.orderBy("createDate");
			page.order(Page.ASC);
		}
		page = labsScopeManager.findPageLabsScope(page, queryfilter);
		return SUCCESS;
	}

	@Override
	public String input() throws Exception {
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		labsScopeManager.saveLabsScope(labsScope);
		return "successMessage";
	}

	@Override
	public String delete() throws Exception {
		return null;
	}

	public void deleteLabsscope(){
		labsScopeManager.deleteLabsScope(id);
		Struts2Utils.renderText("1");
	}
	
	@Override
	protected void prepareModel() throws Exception {
		if (StringUtils.isNotEmpty(id)) {
			labsScope = labsScopeManager.getLabsScope(id);
		} else {
			labsScope = new LabsScope();
		}		
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public LabsScope getLabsScope() {
		return labsScope;
	}

	public void setLabsScope(LabsScope labsScope) {
		this.labsScope = labsScope;
	}

	public String getOrganizationId() {
		return organizationId;
	}

	public void setOrganizationId(String organizationId) {
		this.organizationId = organizationId;
	}

	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	public String getDeptId() {
		return deptId;
	}

	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}

	public String getTypeId() {
		return typeId;
	}

	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}


	public Page<LabsScope> getPage() {
		return page;
	}

	public void setPage(Page<LabsScope> page) {
		this.page = page;
	}

	public LabsScopeManager getLabsScopeManager() {
		return labsScopeManager;
	}

	@Autowired
	public void setLabsScopeManager(LabsScopeManager labsScopeManager) {
		this.labsScopeManager = labsScopeManager;
	}

}
